package com.lanou.musicproject.activity;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import com.lanou.musicproject.R;
import com.lanou.musicproject.base.BaseActivity;
import java.io.File;

/**
 * Created by dllo on 15/10/23.
 */
public class DownloadSeekActivity extends BaseActivity implements View.OnClickListener {
    private TextView downloadSeek;
   private String show_link;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.downloadseek_activity);
        downloadSeek = (TextView) findViewById(R.id.downloadSeek);
        downloadSeek.setOnClickListener(this);
        Intent intent = getIntent();
        if (intent != null) {
            show_link = intent.getStringExtra("show_link");
        }

    }
    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.downloadSeek:
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.setTitle("下载选择");
                builder.setMessage("是否选择下载");
                builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        //此处需要传下载数据下载

                            Toast.makeText(DownloadSeekActivity.this, "你下载本歌曲", Toast.LENGTH_LONG).show();
                            Log.i("++++++++--------->>", show_link);


                        if (Environment.getExternalStorageState().
                                equals(Environment.MEDIA_MOUNTED)) {

                            Environment.getExternalStorageDirectory().getPath();
                            download(show_link, new File("/mnt/sdcard/Download/"));
                            finish();
                        }




                        }

                });

                builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Toast.makeText(DownloadSeekActivity.this, "你取消了本次下载", Toast.LENGTH_LONG).show();
                    }
                });
                builder.create().show();
                break;
        }
    }


}
